package com.nbsaas.boot.product.rest.convert;

import com.nbsaas.boot.product.data.entity.ProductSkuSpecValue;
import com.nbsaas.boot.product.api.domain.request.ProductSkuSpecValueRequest;

import org.springframework.beans.BeanUtils;
import com.nbsaas.boot.rest.api.Converter;
import com.nbsaas.boot.utils.BeanDataUtils;
            import com.nbsaas.boot.product.data.entity.ProductSku;
            import com.nbsaas.boot.product.data.entity.SpecValue;

/**
* 商品SKU规格值请求对象转换成实体对象
*/

public class ProductSkuSpecValueEntityConvert  implements Converter<ProductSkuSpecValue, ProductSkuSpecValueRequest> {

    @Override
    public ProductSkuSpecValue convert(ProductSkuSpecValueRequest source) {
        ProductSkuSpecValue result = new ProductSkuSpecValue();
        BeanDataUtils.copyProperties(source, result);
                    if(source.getProductSku()!=null){
                    ProductSku productSku =new ProductSku();
                    productSku.setId(source.getProductSku());
                    result.setProductSku(productSku);
                    }
                    if(source.getSpecValue()!=null){
                    SpecValue specValue =new SpecValue();
                    specValue.setId(source.getSpecValue());
                    result.setSpecValue(specValue);
                    }
        return result;
    }
}

